package com.sq.partner.manager.service.impl;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.stereotype.Service;

import com.sq.partner.manager.dao.ChannelBusinessRealDao;
import com.sq.partner.manager.dao.impl.BaseDaoImpl;
import com.sq.partner.manager.mybatis.model.ChannelBusinessReal;
import com.sq.partner.manager.service.ChannelBusinessRealService;
import com.sq.partner.manager.util.LogUtil;
import com.sq.partner.manager.util.excel.ExcelEntity;
import com.sq.partner.manager.util.excel.ExportExcelBuilderTool;
@Service
public class ChannelBusinessRealServiceImpl implements ChannelBusinessRealService {
	@Resource
	private ChannelBusinessRealDao channelBusinessRealDao;
	
	private static Logger logger = LogUtil.getLog(BaseDaoImpl.class);

	@Override
	public ChannelBusinessReal queryChannelBusinessReal(String channelCode) throws Exception {
		return channelBusinessRealDao.queryChannelBusinessReal(channelCode);
	}

	@Override
	public void insertChannelBusinessReal(ChannelBusinessReal channelBusinessReal) throws Exception {
		channelBusinessRealDao.insertChannelBusinessReal(channelBusinessReal);
	}

	@Override
	public void updateChannelBusinessRealNotNull(ChannelBusinessReal channelBusinessReal) throws Exception {
		channelBusinessRealDao.updateChannelBusinessRealNotNull(channelBusinessReal);
	}	
	@Resource
	ExportExcelBuilderTool exportExcelBuilderTool;
	/**
	 * 下载渠道信息
	 */
    public void downloadQueryChannelClassification(List<Map<String, Object>> channelClassificationList,HttpServletResponse response) throws Exception {
    	System.out.println("访问到ChannelClassificationServiceImpl。。。");
    	ExcelEntity excel = new ExcelEntity();
    	 excel.setResults(channelClassificationList);
    	 excel.setFileName("channelClassificationInfo");
    	 excel.setTitles("合作伙伴代码,合作伙伴名称,所属机构,对接方式,合作伙伴渠道分类");
    	 excel.setTitleKeys("CHANNEL_CODE,CHANNEL_NAME,DEPT_CNAME,TRANS_TYPE_NAME,CODE_NAME");
    	 excel.setColumns("25,25,25,25,25");
    	 exportExcelBuilderTool.buildExcel(response,excel);
    }
	@Override
	public List<Map<String, Object>> QueryChannelClassification(Map<String, Object> map) throws Exception {
		return channelBusinessRealDao.queryChannelClassification(map);
	}
}
